package com.hcxy.filetransform.dao;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.SQLException;

public class BaseDao {
	static{
		try {
			Class.forName("org.sqlite.JDBC");
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}
	}
	public Connection getConn(){
		try {
			String path=this.getClass().getClassLoader().getResource("transformlog.db").getPath();
			Connection conn = DriverManager.getConnection("jdbc:sqlite:"+path);
			return conn;
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return null;
	}
	public void closeConn(Connection conn){
		if (null!=conn) {
			try {
				conn.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				if (null!=conn) {
					try {
						conn.close();
					} catch (SQLException e) {
						e.printStackTrace();
					}
				}
			}
		}
	}
	public void closeResultSet(ResultSet rs){
		if (null!=rs) {
			try {
				rs.close();
			} catch (SQLException e) {
				e.printStackTrace();
			}finally{
				if (null!=rs) {
					try {
						rs.close();
					} catch (SQLException e) {
						e.printStackTrace();
					}
				}
			}
		}
	}
}
